// Debug Render
// Created by Ruben Rigole

#ifndef DebugRender_h__
#define DebugRender_h__

#include "NxPhysics.h"
#include "../Forest/TreeNode.h"

class PhysX;

/** 
* PhysX klasse om actors visueel weer te geven.
* Tekent lijnen en punten op het scherm.
* @author Ruben Rigole
*/
class DebugRender: public TreeNode
{
public:
	DebugRender();
	virtual ~DebugRender();
	virtual void Tick(float dTime){}
	virtual void Draw();

	void Draw(EffectShadow* effect, int step) {}
	void Init(MeshDesc mDesc) {}

	void RenderData(const NxDebugRenderable* data);

protected:
	
	ID3D10Buffer *m_pVertexBufferPoint, *m_pVertexBufferLine;
	ID3D10InputLayout *m_pVertexDeclaration;
	int m_NumVertices,m_NumIndices;

	ID3D10Effect* m_Effect;
	ID3D10EffectTechnique* m_Tech;
	ID3D10EffectMatrixVariable* m_WorldVar, *m_ViewInvVar, *m_WorldInvVar, *m_WVPVar;

	NxU32 m_Points, m_Lines;
	const NxDebugLine* m_LineData;
	const NxDebugPoint* m_PointData;

	void BuildVertexBufferPoints();
	void BuildVertexBufferLines();
	void BuildIndexBuffer();
	void BuildVertexDeclaration();
	void Init();
	void Cleanup();
	void LoadShader();

	D3DXVECTOR4 MakeColor(NxU32 col);

private:
	// -------------------------
	// Disabling default copy constructor and default assignment operator.
	// If you get a linker error from one of these functions, your class is internally trying to use them. This is
	// an error in your class, these declarations are deliberately made without implementation because they should never be used.
	// -------------------------
	DebugRender(const DebugRender& t);
	DebugRender& operator=(const DebugRender& t);

};

#endif // DebugRender_h__